import sys
from google.protobuf.compiler import plugin_pb2 as plugin

from generator import generate_code


def main():
    # Read the serialized CodeGeneratorRequest from stdin and parse it
    data: bytes = sys.stdin.buffer.read()
    request = plugin.CodeGeneratorRequest.FromString(data)

    response = generate_code(request)
    sys.stdout.buffer.write(response.SerializeToString())


if __name__ == "__main__":
    main()
